package com.approval.approvalapp.index.dbsx.tshf.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.TshfDbXqBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by louyulin on 2019/5/6.
 */

public class TxhfxqAdapter extends RecyclerView.Adapter<TxhfxqAdapter.Holder> {

    List<TshfDbXqBean.HandleoptionsBean> handleoptionsBeanList;
    Context context;

    public void setHandleoptionsBeanList(List<TshfDbXqBean.HandleoptionsBean> handleoptionsBeanList) {
        this.handleoptionsBeanList = handleoptionsBeanList;
        notifyDataSetChanged();
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(context).inflate(R.layout.item_tshfxq, parent, false);
        Holder holder = new Holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
            holder.hfName.setText(handleoptionsBeanList.get(position).getHandleuser());
            holder.hfnrTv.setText(handleoptionsBeanList.get(position).getOpinion());
            holder.hfshTv.setText(handleoptionsBeanList.get(position).getHandledate());
    }

    @Override
    public int getItemCount() {
        if (handleoptionsBeanList == null) {
            return 0;
        } else {
            return handleoptionsBeanList.size();
        }
    }

    class Holder extends RecyclerView.ViewHolder {
        @Bind(R.id.hf_name)
        TextView hfName;
        @Bind(R.id.hfsh_tv)
        TextView hfshTv;
        @Bind(R.id.hfnr_tv)
        TextView hfnrTv;
        @Bind(R.id.hf_ll)
        LinearLayout hfLl;
        public Holder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
